<script lang="ts" setup>
import { useRequest } from 'vue-request'
import axios from 'axios'

interface ParamType {
  age: number
  name: string
}
function serviceMethod(param: ParamType): Promise<any> {
  return axios.get('/api/long-time-get-req', { params: param })
}
const p: ParamType = { name: '黑子', age: 100 }
const { data, loading, error } = useRequest<any, ParamType[]>(serviceMethod, {
  defaultParams: [p],
})
</script>

<template>
  <h3>自动发起请求，且不对响应进行格式化：UseRequestDemo01.vue</h3>
  <div>
    <div v-if="loading">loading...</div>
    <div v-if="error">failed to fetch</div>
    <div v-if="data">Hey! {{ data }}</div>
  </div>
</template>
